# Contributor: Mika Havela <mika.havela@gmail.com>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=swatch
_realname=swatchdog
pkgver=3.2.4
pkgrel=7
pkgdesc="Logfile monitoring tool"
url="https://sourceforge.net/projects/swatch/"
arch="noarch"
license="GPL-2.0-only"
depends="perl perl-date-calc perl-date-format perl-date-manip perl-file-tail perl-carp-clan"
makedepends="perl-dev"
subpackages="$pkgname-doc $pkgname-openrc"
source="
	$pkgname-$pkgver.tar.gz::https://downloads.sourceforge.net/project/$pkgname/$_realname/$_realname-$pkgver.tar.gz
	swatch.initd
	swatch.confd
	swatchrc
	"

builddir="$srcdir"/$_realname-$pkgver

build() {
	PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
	make
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
	make realclean

	# remove perllocal.pod and .packlist
	find "$pkgdir" -name perllocal.pod -delete
	find "$pkgdir" -name .packlist -delete

	mkdir -p "$pkgdir"/etc/init.d/ "$pkgdir"/etc/conf.d/ \
		"$pkgdir"/etc/$pkgname/

	cp "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	cp "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	cp "$srcdir"/${pkgname}rc "$pkgdir"/etc/$pkgname/${pkgname}rc

	chmod 755 "$pkgdir"/etc/init.d/$pkgname
}

sha512sums="4e0a4e3feed00df0f0d04f94cc090e53e71fa9b20d46236ec41d63b98b5733d80a5941b491cffcbb0b655a9c7d2b5c9423ca7ae043346dbe1b05ee6ab24b9489  swatch-3.2.4.tar.gz
4d274d4875664dee989016be71d8e72583766b88da684a4f0c242ec8d7b213c2a917395ee15cd5d446d2dbbfc9665bb75729e010a8fdcc6ba12985a19354b0ca  swatch.initd
493f3e54e6472ee349c3d56537d3ad88405936d6551defa802911625e84a9afabc13c4975e2edfe63e723c48cfdfe09b966e807d05ca218b4cd238889b656fde  swatch.confd
6579b3e998640f571097cddb65c7772f62855605fb38fbeb4e53976d72faacb6bdb90f7392727170e0e523d19ae74f19b30ec5fd0c5fab8c67f64976ee0f2d73  swatchrc"
